// var getIntegralsDetail = "http://localhost:8080/hjcr-wechat/bill/getIntegrationBillbyUser";
var getIntegralsDetail = "./json/integralDetail.json";
$(document).ready(function(){
  var page=0;
  var totalPage =0;
  function getRecord(num,size){
    $.get(getIntegralsDetail,{params:{userId:sessionStorage.userId,currentPage:num,size:size}},function (res) {
      if(res.serviceResult){
        var data = res.resultParm.list;
        totalPage = res.resultParm.totalPages;
        var html = "";
        for (var i = 0; i < data.length; i++) {
          var add = "";var fu = "";
          if (data[i].integration>0) {
            add="add";
            fu = "+";
          }
          html +=   '<div class="bill-item row">'+
                      '<div class="col-18">'+
                        '<span class="title">'+data[i].billType+'</span>'+
                        '<span class="meta">'+data[i].createTime+'</span>'+
                      '</div>'+
                      '<div class="col-6">'+
                        '<span class="price '+add+'">'+
                          fu+data[i].integration+
                        '</span>'+
                      '</div>'+
                    '</div>';
        }
        $(".bill-list").empty().append(html);
      }
    })

  }
  getRecord(0,15);
  $(document).scroll(function() {
    if(document.body.scrollHeight-document.body.scrollTop<=window.screen.availHeight){
      if(page<totalPage-1){
        getRecord(++page,15);
      }
    }
  });
});
